home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c,comp.unix.aix
- Path: ritz.mordor.com!news
- From: benjamin@ritz.mordor.com (Joseph Thomas)
- Subject: Help: write() to a socket hangs unless there's a newline
- X-Newsreader: Gnus v5.1
- X-Nntp-Posting-User: benjamin
- Sender: benjamin@ritz.mordor.com
- Organization: none
- Message-ID: <5r68cae4wm.fsf@ritz.mordor.com>
- X-Nntp-Posting-Host: ritz.mordor.com
- Date: Tue, 12 Mar 1996 14:56:41 GMT
-
- I realize this is not a direct C question, but it does have to do with
- streams, and I tend to think the expertise to answer this is here:
-
- I've opened a socket, and connected it to another. I'm using write() to
- send a message through, ex:
-
- write(sock_fd, "Hello world", strlen("Hello world"));
-
- When I do this, the message gets through to the other socket, but the
- write() call hangs in the process that executed it.
-
- However, if I send it as:
-
- write(sock_fd, "Hello world\n", strlen("Hello world\n"));
-
- It doesn't hang, but I have a newline I don't want at the other end.
- In addition, for some reason, between the next write()-->read() that I
- try, I read() two null strings before I actually get the next
- message (this may be something particular to sockets?)
-
- I've tried using fflush(sock_fd), but that causes a broken pipe for
- some reason. Can anyone say what gives here?
-
- Please, no advice about not using write()
-
- TIA
- -Joe
-